package com.qingcheng.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.qingcheng.dao.StockMapper;
import com.qingcheng.entity.PageResult;
import com.qingcheng.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class StockServiceImpl implements StockService {

    @Autowired(required = false)
    private StockMapper mapper;


    @Override
    public PageResult<Map> findAllStock(String name,String date1,Integer page, Integer size) {
        PageHelper.startPage(page,size);
        Page<Map>pageinfo= (Page<Map>) this.mapper.findAllStock(name,date1);
        return new PageResult<>(pageinfo.getTotal(),pageinfo.getResult()) ;
    }

    @Override
    public PageResult<Map> findOutStock(String name, String date1, Integer page, Integer size) {
        PageHelper.startPage(page,size);
        Page<Map>pageinfo= (Page<Map>) this.mapper.findOutStock(name, date1);
        return new PageResult<>(pageinfo.getTotal(),pageinfo.getResult()) ;
    }


}
